import { http } from '@/utils/http/axios';
export interface BasicResponseModel<T = any> {
  code: number;
  message: string;
  result: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}
export type LoginParams = {
  username: string;
  password: string;
  code: string;
  randomStr: string;
};
/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return http.request({
    url: '/admin/user/info',
    method: 'get',
  });
}
/**
 * @description: 用户修改密码
 */
export function changePassword(params, uid) {
  return http.request(
    {
      url: `/admin/user/u${uid}/changepw`,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户登出
 */
export function logout() {
  return http.request({
    url: '/auth/token/logout',
    method: 'delete',
  });
}

export function fetchList(query) {
  return http.request({
    url: '/admin/user/page',
    method: 'post',
    params: query,
  });
}

export function delObj(id) {
  return http.request({
    url: '/admin/user/' + id + '/delete',
    method: 'delete',
  });
}
